package com.gitee.wsl.compose.ui.theme


import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi
import androidx.compose.runtime.Composable
import androidx.compose.runtime.Stable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.structuralEqualityPolicy
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.material3.windowsizeclass.WindowHeightSizeClass
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.remember


/**
 * Dimens for Salt UI.
 *
 *   ╭──────────────────────────────────────────────────╮
 *   │ ------------------[padding] * 0.5f               │
 *   │           ╭──────────────────────────╮           │
 *   │           │ ------[subPadding]       │           │
 *   │ [padding] │ [padding] Text [padding] │ [padding] │
 *   │           │ ------[subPadding]       │           │
 *   │           ╰──────────────────────────╯           │
 *   │ ------------------[padding] * 0.5f               │
 *   │ ------------------[padding] * 0.5f               │
 *   │           ╭──────────────────────────╮           │
 *   │           │ ------[subPadding]       │           │
 *   │ [padding] │ [padding] Text [padding] │ [padding] │
 *   │           │ ------[subPadding]       │           │
 *   │           ╰──────────────────────────╯           │
 *   │ ------------------[padding] * 0.5f               │
 *   ╰──────────────────────────────────────────────────╯
 *
 * @param padding Padding.
 * @param subPadding Sub padding.
 */
@Stable
class SaltDimens(
    padding: Dp,
    subPadding: Dp
) {
    //val item by mutableStateOf(item, structuralEqualityPolicy())
    //val itemIcon by mutableStateOf(itemIcon, structuralEqualityPolicy())

    val padding by mutableStateOf(padding, structuralEqualityPolicy())
    val subPadding by mutableStateOf(subPadding, structuralEqualityPolicy())

    @Suppress("DEPRECATION")
    fun copy(
        //item: Dp = this.item,
        //itemIcon: Dp = this.itemIcon,
        padding: Dp = this.padding,
        subPadding: Dp = this.subPadding
    ): SaltDimens = SaltDimens(
        //item = item,
        //itemIcon = itemIcon,
        padding = padding,
        subPadding = subPadding
    )
}

fun phoneDimensions(
    padding: Dp = 16.dp,
    subPadding: Dp = 12.dp
): SaltDimens = SaltDimens(
    padding = padding,
    subPadding = subPadding
)

fun tabletDimensions(
    padding: Dp = 16.dp,
    subPadding: Dp = 12.dp
): SaltDimens = SaltDimens(
    padding = padding,
    subPadding = subPadding
)


//@OptIn(ExperimentalMaterial3WindowSizeClassApi::class)
//@Composable
//fun ProvideDimens(content: @Composable () -> Unit) {
//    val windowSizeClass = calculateWindowSizeClass()
//
//    val dimensionSet =
//        remember {
//                when (windowSizeClass.widthSizeClass) {
//                    WindowWidthSizeClass.Compact -> phoneDimensions()
//                    else -> {
//                        when (windowSizeClass.heightSizeClass) {
//                            WindowHeightSizeClass.Compact -> phoneDimensions()
//                            else ->
//                                tabletDimensions()
//                        }
//                    }
//                }
//        }
//
//    CompositionLocalProvider(LocalDimens provides dimensionSet, content = content)
//}
